<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f= "http://java.sun.com/jsf/core">



    <h:head>

    </h:head>
    <h:body onload="document.getElementById('form1:nome').focus()">
        <ui:composition template="#{mudarTemplateBean.template}">
            <ui:define name="centro">
                <!--p:messages globalOnly="true" showDetail="true" /-->

                <div id="divCentro">
                    <p:messages globalOnly="true" showDetail="true" />
                    <p:panel header="#{mens.CADASTRO_DE_FORNECEDOR}" visible="true" toggleable="true" styleClass="painelCentral" >

                        <h:form id="form1">
                            <h:inputHidden value="#{manterFornecedorBean.fornecedor.codigo}"/>
                            <h:outputLabel value="#{mens.DADOS_PESSOAIS}" style="font-style: oblique; font-style: italic; font-weight: bolder; font-size: larger  "/>
                            <h:panelGrid  id="panelPessoal"  columns="6"     >

                                <h:outputText value="#{mens.NOME}" styleClass="outputText"/>
                                <p:inputText id="nome" value="#{manterFornecedorBean.fornecedor.nome}" required="true" size="30">
                                    <f:validateLength for="nome" minimum="1" maximum="50"/>
                                </p:inputText>
                                <p:message for="nome"/>


                                <h:outputText value="#{mens.CNPJ}" styleClass="outputText"/>
                                <p:inputMask id="cnpj" mask="99.999.999/9999-99" value="#{manterFornecedorBean.fornecedor.cnpj}" required="true" size="30"/>
                                <p:message for="cnpj"/>


                                <h:outputText value="#{mens.RAZAO_SOCIAL}" styleClass="outputText"/>
                                <p:inputText id="razaoSocial" value="#{manterFornecedorBean.fornecedor.razaoSocial}" required="true" size="30">
                                    <f:validateLength for="razaoSocial" minimum="1" maximum="50"/>
                                </p:inputText>
                                <p:message for="razaoSocial"/>

                                <h:outputText value="#{mens.MATERIAL_FORNECIDO}" escape="false"/>
                                <h:selectOneMenu id="menuItens">
                                    <f:selectItem itemLabel=""/>
                                    <f:selectItem itemLabel="Algodão"/>
                                    <f:selectItem itemLabel="Pano"/>
                                    <f:selectItem itemLabel="Fio"/>
                                                                            
                                </h:selectOneMenu>
                                <p:message for="menuItens"/>
                                
                                <h:outputText value="#{mens.TELEFONE}" styleClass="outputText"/>
                                <p:inputMask id="telefone" mask="(99)9999-9999" value="#{manterFornecedorBean.fornecedor.telefone}" required="true" size="30"/>
                                <p:message for="telefone"/>


                                <h:outputText value="#{mens.EMAIL}" styleClass="outputText"/>
                                <p:inputText id="email" value="#{manterFornecedorBean.fornecedor.email}" size="30">
                                    <f:validateLength for="email" maximum="50"/>
                                </p:inputText>
                                <p:message for="email"/>

                            </h:panelGrid>
                            <p:separator />
                            <h:outputLabel value="#{mens.ENDERECO}" style="font-style: oblique; font-style: italic; font-weight: bolder; font-size: larger "/>

                            <h:panelGrid id="panelEndereco" columns="6" >
                                <h:outputText value="#{mens.PAIS}" styleClass="outputText"/>
                                <p:inputText id="pais" value="#{manterFornecedorBean.endereco.pais}" size="30" required="true">
                                    <f:validateLength for="pais" maximum="100"/>
                                </p:inputText>
                                <p:message for="pais"/>

                                <h:outputText value="#{mens.ESTADO}" styleClass="outputText"/>
                                <p:inputText id="estado" value="#{manterFornecedorBean.endereco.estado}" size="30" required="true">
                                    <f:validateLength for="estado" maximum="100"/>
                                </p:inputText>
                                <p:message for="estado"/>

                                <h:outputText value="#{mens.CIDADE}" styleClass="outputText"/>
                                <p:inputText id="cidade" value="#{manterFornecedorBean.endereco.cidade}" size="30" required="true">
                                    <f:validateLength for="cidade" maximum="100"/>
                                </p:inputText>
                                <p:message for="cidade"/>

                                <h:outputText value="#{mens.BAIRRO}" styleClass="outputText"/>
                                <p:inputText id="bairro" value="#{manterFornecedorBean.endereco.bairro}" size="30" required="true">
                                    <f:validateLength for="bairro" maximum="100"/>
                                </p:inputText>
                                <p:message for="bairro"/>

                                <h:outputText value="#{mens.RUA}"  styleClass="outputText"/>
                                <p:inputText id="rua" value="#{manterFornecedorBean.endereco.rua}" size="30" required="true">
                                    <f:validateLength for="rua" maximum="100"/>
                                </p:inputText>
                                <p:message for="rua"/>


                                <h:outputText value="#{mens.NUMERO}" styleClass="outputText"/>
                                <p:inputText id="numero" value="#{manterFornecedorBean.endereco.numero}" size="30" required="true">
                                    <f:validateLength for="numero" maximum="100"/>
                                </p:inputText>
                                <p:message for="numero"/>

                                <h:outputText value="#{mens.CEP}"  styleClass="outputText"/>
                                <p:inputMask id="cep" mask="99.999-999" value="#{manterFornecedorBean.endereco.cep}" size="30" required="true"/>
                                <p:message for="cep"/>

                                <h:outputText value="#{mens.COMPLEMENTO}" styleClass="outputText"/>
                                <p:inputText id="complemento" value="#{manterFornecedorBean.endereco.complemento}" size="30" required="true">
                                    <f:validateLength for="complemento" maximum="500"/>
                                </p:inputText>
                                <p:message for="complemento"/>
                            </h:panelGrid>

                            <h:panelGrid cellspacing="5" columns="3">

                                <p:commandButton ajax="false" value="#{mens.INSERIR}" action="#{manterFornecedorBean.create}" />
                                <p:commandButton ajax="false" value="#{mens.ALTERAR}" action="#{manterFornecedorBean.edit}" disabled="#{manterFornecedorBean.naoSelecionouFornecedor}"/>
                                <p:commandButton ajax="false" value="#{mens.EXCLUIR}" action="#{manterFornecedorBean.destroy}" disabled="#{manterFornecedorBean.naoSelecionouFornecedor}"/>
                            </h:panelGrid>

                        </h:form>

                        <h:form>
                            <h:panelGrid>
                                <p:panel header="#{mens.PESQUISAR_POR}">
                                    <h:selectOneMenu >
                                        <f:selectItem itemLabel=""/>
                                        <f:selectItem itemLabel="Nome"/>
                                        <f:selectItem itemLabel="Codigo"/>

                                    </h:selectOneMenu>
                                    <p:inputText  style="margin-left: 5px"/>
                                    <p:commandButton value="#{mens.PESQUISAR}" action="#{manterFornecedorBean.findFornecedorEntities}" image="url(../img/pesquisa2.png)" ajax="false" />

                                </p:panel>
                            </h:panelGrid>

                        </h:form>

                    </p:panel>

                    <h:form>
                        <p:panel header="#{mens.PAINEL_DE_PESQUISA}" visible="true" toggleable="true" styleClass="painelCentral">

                            <p:dataTable paginator="true" rows="4" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5" var="f" emptyMessage="#{mens.TABELA_VAZIA}" value="#{manterFornecedorBean.fornecedores}" style="width:620px" rendered="#{manterFornecedorBean.exibeTabela}">
                                <p:column style="width: 103px; max-width: 103px">
                                    <f:facet name="header">
                                        <h:outputText value="#{mens.NOME}"/>
                                    </f:facet>
                                    <h:commandLink style="color: maroon; font-weight: bolder" value="#{f.nome}" action="paginaManterFornecedorTeste.xhtml">
                                        <f:setPropertyActionListener value="#{f.codigo}" target="#{manterFornecedorBean.fornecedor.codigo}"/>
                                        <f:setPropertyActionListener value="#{f.nome}" target="#{manterFornecedorBean.fornecedor.nome}"/>
                                        <f:setPropertyActionListener value="#{f.cnpj}" target="#{manterFornecedorBean.fornecedor.cnpj}"/>
                                        <f:setPropertyActionListener value="#{f.razaoSocial}" target="#{manterFornecedorBean.fornecedor.razaoSocial}"/>
                                        <f:setPropertyActionListener value="#{f.telefone}" target="#{manterFornecedorBean.fornecedor.telefone}"/>
                                        <f:setPropertyActionListener value="#{f.email}" target="#{manterFornecedorBean.fornecedor.email}"/>
                                        <f:setPropertyActionListener value="#{f.endereco}" target="#{manterFornecedorBean.endereco}"/>
                                        <f:setPropertyActionListener value="false" target="#{manterFornecedorBean.naoSelecionouFornecedor}"/>
                                    </h:commandLink>
                                </p:column>
                                <p:column style="width: 100px; max-width: 100px;">
                                    <f:facet name="header">
                                        <h:outputText value="#{mens.CNPJ}"/>
                                    </f:facet>
                                    <h:outputText value="#{f.cnpj}"/>
                                </p:column>
                                <p:column style="width: 103px">
                                    <f:facet name="header">
                                        <h:outputText value="#{mens.RAZAO_SOCIAL}"/>
                                    </f:facet>
                                    <h:outputText value="#{f.razaoSocial}"/>
                                </p:column>
                                <p:column style="width: 70px; max-width: 70px;">
                                    <f:facet name="header">
                                        <h:outputText value="#{mens.TELEFONE}"/>
                                    </f:facet>
                                    <h:outputText value="#{f.telefone}"/>
                                </p:column>
                                <p:column style="width: 103px">
                                    <f:facet name="header">
                                        <h:outputText value="#{mens.EMAIL}"/>
                                    </f:facet>
                                    <h:outputText value="#{f.email}"/>
                                </p:column>

                                <p:column style="width: 103px">
                                    <f:facet name="header">
                                        <h:outputText value="#{mens.ENDERECO}"/>
                                    </f:facet>
                                    <h:form>
                                        <h:outputText value="#{f.endereco.pais}"/>
                                        <h:outputText value=", "/>

                                        <h:outputText value="#{f.endereco.estado}"/>
                                        <h:outputText value=", "/>


                                        <h:outputText value="#{f.endereco.cidade}"/>
                                        <h:outputText value=", "/>


                                        <h:outputText value="#{f.endereco.bairro}"/>
                                        <h:outputText value=", "/>


                                        <h:outputText value="#{f.endereco.rua}"/>
                                        <h:outputText value=", "/>


                                        <h:outputText value="#{f.endereco.numero}"/>
                                        <h:outputText value=", "/>


                                        <h:outputText value="#{f.endereco.cep}"/>
                                        <h:outputText value=", "/>


                                        <h:outputText value="#{f.endereco.complemento}"/>

                                    </h:form>
                                </p:column>

                            </p:dataTable>
                        </p:panel>
                    </h:form>
                </div>

            </ui:define>
        </ui:composition>
    </h:body>
</html>

